package buttons.view;

import java.awt.Color;

import processing.core.PApplet;

public class V_CheckBox extends V_ToggleButton
{
  // create a button with the given text and a width/height
  public V_CheckBox(String n, float xWidth, float yHeight){
    super(n, xWidth, yHeight);
    this.setBGColor(new Color(255, 255, 255));
    this.setToggleColor(new Color(0,0,0));
  }
  
  @Override
  public void display(PApplet p)
  {
    if(visible)
    { 
      if(over)
      {
        offset -= 40;
      }
      
      int tmpColor = p.color(p.red(bgColor)+offset, p.green(bgColor)+offset, p.blue(bgColor)+offset, transp); 
      p.fill(0,0,0,transp); 
      
      // draw the text label:
      if(B_Font != null)
	  {
    	  p.textFont(B_Font);
    	  p.text(name, xLoc - p.textWidth(name)-1, yLoc+fontSize); 
	  }
      
      p.stroke(0,0,0,transp);
      p.fill(tmpColor);
      p.rect(xLoc, yLoc, xSize, ySize);
      p.fill(0);
      
      // draw the toggle shape inside the box:
      if(toggle) {
        p.ellipse(xLoc+(xSize/2), yLoc+(ySize/2), 6, 6); 
      }
      
    }
  }
}
